{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "BRUNO DA SILVA 396433 - CK0223\n",
    "\n",
    "# Regressão Linear Simples - Trabalho\n",
    "\n",
    "## Estudo de caso: Seguro de automóvel sueco\n",
    "\n",
    "Agora, sabemos como implementar um modelo de regressão linear simples. Vamos aplicá-lo ao conjunto de dados do seguro de automóveis sueco. Esta seção assume que você baixou o conjunto de dados para o arquivo insurance.csv, o qual está disponível no notebook respectivo.\n",
    "\n",
    "O conjunto de dados envolve a previsão do pagamento total de todas as reclamações em milhares de Kronor sueco, dado o número total de reclamações. É um dataset composto por 63 observações com 1 variável de entrada e 1 variável de saída. Os nomes das variáveis são os seguintes:\n",
    "\n",
    "1. Número de reivindicações.\n",
    "2. Pagamento total para todas as reclamações em milhares de Kronor sueco.\n",
    "\n",
    "Voce deve adicionar algumas funções acessórias à regressão linear simples. Especificamente, uma função para carregar o arquivo CSV chamado *load_csv ()*, uma função para converter um conjunto de dados carregado para números chamado *str_column_to_float ()*, uma função para avaliar um algoritmo usando um conjunto de treino e teste chamado *split_train_split ()*, a função para calcular RMSE chamado *rmse_metric ()* e uma função para avaliar um algoritmo chamado *evaluate_algorithm()*.\n",
    "\n",
    "Utilize um conjunto de dados de treinamento de 60% dos dados para preparar o modelo. As previsões devem ser feitas nos restantes 40%. \n",
    "\n",
    "Compare a performabce do seu algoritmo com o algoritmo baseline, o qual utiliza a média dos pagamentos realizados para realizar a predição ( a média é 72,251 mil Kronor).\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "from matplotlib import pyplot as plt\n",
    "from math import sqrt\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "\n",
    "#função para carregar o arquivo CSV\n",
    "def load_csv(filename):\n",
    "    dataset = pd.read_csv(filename, header=None)\n",
    "    return np.array(dataset)\n",
    "           \n",
    "def mean(values):\n",
    "    return sum(values) / float(len(values))\n",
    "\n",
    "def variance(values, mean):\n",
    "    return sum([(x-mean)**2 for x in values])\n",
    "\n",
    "#Calcular covariância entre x e y\n",
    "def covariance(x, mean_x, y, mean_y):\n",
    "    covar = 0.0\n",
    "    for i in range(len(x)):\n",
    "        covar += (x[i] - mean_x) * (y[i] - mean_y)\n",
    "    return covar\n",
    "\n",
    "def coefficients(dataset):\n",
    "    x = [row[0] for row in dataset]\n",
    "    y = [row[1] for row in dataset]\n",
    "    x_mean, y_mean = mean(x), mean(y)\n",
    "    b1 = covariance(x, x_mean, y, y_mean) / variance(x, x_mean)\n",
    "    b0 = y_mean - b1 * x_mean\n",
    "    return [b0, b1]\n",
    "\n",
    "#função para calcular RMSE\n",
    "def rmse_metric(actual, predicted):\n",
    "    sum_error = 0.0\n",
    "    for i in range(len(actual)):\n",
    "        prediction_error = predicted[i] - actual[i]\n",
    "        sum_error += (prediction_error ** 2)\n",
    "        mean_error = sum_error / float(len(actual))\n",
    "    return sqrt(mean_error)\n",
    "\n",
    "#função para avaliar algoritmo\n",
    "def evaluate_algorithm(ds_train, ds_test, algorithm):\n",
    "    test_set = list()\n",
    "    for row in dataset:\n",
    "        row_copy = list(row)\n",
    "        row_copy[-1] = None\n",
    "        test_set.append(row_copy)\n",
    "        predicted = algorithm(dataset, test_set)\n",
    "        print(predicted)\n",
    "        actual = [row[-1] for row in dataset]\n",
    "        rmse = rmse_metric(actual, predicted)\n",
    "    return rmse\n",
    "\n",
    "def simple_linear_regression(train, test):\n",
    "    predictions = list()\n",
    "    b0, b1 = coefficients(train)\n",
    "    for row in test:\n",
    "        ypred = b0 + b1 * row[0]\n",
    "        predictions.append(ypred)\n",
    "    return predictions   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[466.94144405059473,\n",
       " 238.12706713424961,\n",
       " 45.632432585578385,\n",
       " 42.000458348811001,\n",
       " 67.424278006182675,\n",
       " 85.584149190019588,\n",
       " 42.000458348811001,\n",
       " 63.792303769415298,\n",
       " 74.688226479717443,\n",
       " 63.792303769415298,\n",
       " 56.52835529588053,\n",
       " 209.0712732401106,\n",
       " 49.264406822345769,\n",
       " 42.000458348811001,\n",
       " 121.90389155769341,\n",
       " 165.48758239890202,\n",
       " 103.7440203738565,\n",
       " 100.11204613708912,\n",
       " 63.792303769415298,\n",
       " 89.216123426786979,\n",
       " 96.480071900321732,\n",
       " 223.59917018718011,\n",
       " 161.85560816213462,\n",
       " 52.896381059113153,\n",
       " 63.792303769415298,\n",
       " 114.63994308415865]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "filename = 'insurance.csv'\n",
    "dataset = load_csv(filename)\n",
    "ds_train, ds_test = train_test_split(dataset, test_size = 0.4)\n",
    "simple_linear_regression(ds_train, ds_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWQAAADuCAYAAAAOR30qAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAHdpJREFUeJzt3Xt8U2WeP/DPSdpS2gKFlJtAEwVFkJtQhC4gIlCgDevOzq7D7xV2/aE75TJCQeXHSIW2StRxvHVELh1HdhwyO6/ddS9DCgUsvwoVO1gUFWQZQNoCcmu590Lb5OwfTNOmPadN2iTnSfJ5v168XvrkJHkQ+fDw/T7nOZIsyyAiIu3ptJ4AERHdxUAmIhIEA5mISBAMZCIiQTCQiYgEwUAmIhIEA5mISBAMZCIiQTCQiYgEEeHNxQkJCbLJZPLTVIiIQtPhw4crZVnu29F1XgWyyWRCaWlp52dFRBSGJEkq9+Q6liyIiATBQCYiEgQDmYhIEAxkIiJBMJCJiATBQC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IgpfRlmW+3Z0kVeBTERE/sOSBRGRIBjIRESCYCATEQmCgUxEJAgGMhGRIBjIRESCYCATEQmCgUxEJAgGMhGRIP4XiQxY8aVYmREAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x29c30bc9b0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(dataset[:,0], dataset[:,1],  color='black')\n",
    "plt.plot(ds_test[:,0], simple_linear_regression(ds_train, ds_test), color='purple', linewidth=3)\n",
    "\n",
    "plt.xticks(())\n",
    "plt.yticks(())\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
